import subprocess

# 方法1:
ret = subprocess.run(["ls -l /dev/null"], shell=True, capture_output=True)
print("输出:", ret.stdout.decode("utf-8"))
print("错误:", ret.stderr.decode("utf-8"))
"""crw-rw-rw- 1 root root 1, 3 Dec 20 09:46 /dev/null"""

# 方法2:
output = subprocess.check_output(["ls", "-l", "/dev/null"])
print("输出:", output.decode("utf-8"))
""" crw-rw-rw- 1 root root 1, 3 Dec 20 09:46 /dev/null"""


# 方法3:
output = subprocess.check_output(["ls -l /dev/123"], shell=True)
print("输出3:", output.decode("utf-8"))
